'use strict';
define([
    'angular',
    'ngRoute',
    'services/getApiServices',
], function(angular) {
    return angular.module('myApp.register', [
            'ngRoute',
            'myApp.services.getApiServices',
        ])
        .config([
            '$routeProvider',
            function($routeProvider) {
                $routeProvider.when('/register', {
                    templateUrl: '../template/register.html',
                    controller: 'registerCtrl'
                });
            }
        ])
        .controller('registerCtrl', [
            '$scope',
            '$routeParams',
            'ApiIterface',
            function($scope, $routeParams, ApiIterface) {
                $scope.userInfo = {
                    username: '',
                    userpass: '',
                };
                $scope.rev = '';
                $scope.register = () => {
                        ApiIterface
                            .register($scope.userInfo)
                            .then(res => {
                                $scope.rev = res.data;
                            })
                            .catch(err => console.log(err));
                    }

            }
        ]);
});